package com.zt.location.modules.base.controller;

import java.util.List;
import java.util.Map;

import com.zt.location.common.utils.PageUtils;
import com.zt.location.common.utils.Query;
import com.zt.location.common.utils.R;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.zt.location.modules.base.entity.TdMsgEntity;
import com.zt.location.modules.base.service.TdMsgService;


/**
 * 
 * 
 * @author admin
 * @email obj_admin@163.com
 * @date 2019-06-20 11:07:19
 */
@RestController
@RequestMapping("/base/tdmsg")
public class TdMsgController {
    @Autowired
    private TdMsgService tdMsgService;

    /**
     * 列表
     */
    @RequestMapping("/qlist") 
    public R qlist(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);

        List<TdMsgEntity> tdMsgList = tdMsgService.queryList(query);

        return R.ok().put("tdMsgList", tdMsgList);
    }
    
    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("base:tdmsg:list")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);

        List<TdMsgEntity> tdMsgList = tdMsgService.queryList(query);
        int total = tdMsgService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(tdMsgList, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("base:tdmsg:info")
    public R info(@PathVariable("id") Integer id){
			TdMsgEntity tdMsg = tdMsgService.queryObject(id);

        return R.ok().put("tdMsg", tdMsg);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("base:tdmsg:save")
    public R save(@RequestBody TdMsgEntity tdMsg){
			tdMsgService.save(tdMsg);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("base:tdmsg:update")
    public R update(@RequestBody TdMsgEntity tdMsg){
			tdMsgService.update(tdMsg);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("base:tdmsg:delete")
    public R delete(@RequestBody Integer[] ids){
			tdMsgService.deleteBatch(ids);

        return R.ok();
    }
	
}
